package com.shuo.dsa.leetcode;

/**
 * Created by shuoGG on 2018/10/22 0022
 */
public class Router {
    public int router(int n, int k, int[] array) {
        int[] ret = new int[array.length];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = 1;
        }
        for (int i = 0; i < array.length; i++) {
            for (int j = 1; j <= array[i]; j++) {
                if (i + j <= array.length - 1)
                    ret[i + j] += 1;
                if (i - j >= 0)
                    ret[i - j] += 1;
            }
        }
        int num = 0;
        for (int aRet : ret) {
            if (aRet == k) num++;
        }
        return num;
    }

    public static void main(String[] args) {
        System.out.println(new Router().router(4, 4, new int[]{3, 3, 3, 3}));
    }
}
